package org.dromara.akali.spring;

import org.dromara.akali.Akali;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class AkaliScanner implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        try {
            return Akali.register(bean);
        } catch (Exception e) {
            throw new BeanInitializationException(e.getMessage());
        }
    }
}
